package com.fire.control.system.module.index.controller.web;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.fire.control.system.dto.UserDTO;
import com.fire.control.system.module.common.controller.BaseController;
import com.fire.control.system.module.device.service.DeviceService;
import com.fire.control.system.standard.BusinessInterfaceStandard;
import com.fire.control.system.support.protocol.comman.ResponseProtocol;
import com.fire.control.system.support.protocol.device.DeviceRequestProtocol;


/**
* @ClassName: IndexController
* @Description: TODO(web 首页)
* @author wanbo
* @date 2017年6月13日 下午5:11:28
*/
@RestController
@RequestMapping(value="/web")
public class WebIndexController extends BaseController implements BusinessInterfaceStandard<DeviceRequestProtocol,ResponseProtocol> {
	
	private static final Logger logger = LoggerFactory.getLogger(WebIndexController.class);
	@Autowired private DeviceService deviceService;
	
	@RequestMapping
	public String index(DeviceRequestProtocol requestProtocol){
		System.out.println("进入首页");
		return "/index";
	}
	
	/**
	 * 
	 * @Title: getSysCount   
	 * @Description: 获取系统数据统计  
	 * @param:  requestProtocol     
	 * @return: ResponseProtocol      
	 * @throws
	 */
	@RequestMapping(value="/index/getSysCount", method=RequestMethod.POST)
	public ResponseProtocol getSysCount(DeviceRequestProtocol requestProtocol) {
		logger.info("getSysCount (" + requestProtocol.getTaskuuid() + ") task In time: "+System.currentTimeMillis());
		UserDTO user = getUser();
		ResponseProtocol response =  deviceService.getSysCount(requestProtocol, user);
		logger.info("getSysCount (" + requestProtocol.getTaskuuid() + ") task Out time: "+System.currentTimeMillis());
		return response;
	}
	
	/**
	 * 
	 * @Title: index   
	 * @Description: web端获取所有设备,不分页
	 * @param:        
	 * @return: ResponseJsonProtocol      
	 * @throws
	 */
	@RequestMapping(value = "/index/getDevices", method = RequestMethod.POST)
	public ResponseProtocol getDevices(DeviceRequestProtocol requestProtocol){
		logger.info("getDevices (" + requestProtocol.getTaskuuid() + ") task In time: "+System.currentTimeMillis());
		UserDTO user = getUser();
		ResponseProtocol response = deviceService.getDevices(requestProtocol, user);
		logger.info("getDevices (" + requestProtocol.getTaskuuid() + ") task Out time: "+System.currentTimeMillis());
		return response;
	}
	
	/**
	 * 
	 * @Title: searchDeviceByName   
	 * @Description: 根据设备名称查找设备  
	 * @param:  requestProtocol     
	 * @return: ResponseProtocol      
	 * @throws
	 */
	@RequestMapping(value="/index/searchDeviceByName", method=RequestMethod.POST)
	public ResponseProtocol searchDeviceByName(DeviceRequestProtocol requestProtocol) {
		logger.info("searchDeviceByName (" + requestProtocol.getTaskuuid() + ") task In time: "+System.currentTimeMillis());
		UserDTO user = getUser();
		ResponseProtocol response = deviceService.searchDeviceByName(requestProtocol, user);
		logger.info("searchDeviceByName (" + requestProtocol.getTaskuuid() + ") task In time: "+System.currentTimeMillis());
		return response;
	}
	
}
